package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.JsonMsgDto;
import com.hualude.roadsign.service.HighLeverLocationCountService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by xu_jiaHui on 2018/3/24.
 */
@Controller
@RequestMapping("/rds_highLeverLocationCount")
public class HighLeverLocationCountController {
    @Resource
    private HighLeverLocationCountService highLeverLocationCountService;

    @RequestMapping(value = "/getHighLever4DT")
    @ResponseBody
    public DTResponseDto getHighLever4DT(Integer userId, Integer orgId, DTRequestDto dtRequestDto) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = highLeverLocationCountService.getHighLever4DT(userId, orgId, dtRequestDto);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping(value = "/getProvinceName")
    @ResponseBody
    public JsonMsgDto getProvinceName(Integer userId, Integer orgId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(highLeverLocationCountService.getProvinceName(userId, orgId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getCityName")
    @ResponseBody
    public JsonMsgDto getCityName(Integer userId, Integer orgId, String provinceName) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(highLeverLocationCountService.getCityName(userId, orgId, provinceName));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getAllAreaName")
    @ResponseBody
    public JsonMsgDto getAllAreaName(Integer userId, Integer orgId, String provinceName, String cityName) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(highLeverLocationCountService.getAllAreaName(userId, orgId, provinceName, cityName));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getAllRoadName")
    @ResponseBody
    public JsonMsgDto getAllRoadName(String provinceName, String cityName, String areaName, Integer userId, Integer orgId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(highLeverLocationCountService.getAllRoadName(provinceName, cityName, areaName, userId, orgId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getStartRoadName")
    @ResponseBody
    public JsonMsgDto getStartRoadName(Integer userId, Integer orgId, String provinceName, String cityName,
                                       String areaName, String endRoadName, String roadName) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(highLeverLocationCountService.getStartRoadName(userId, orgId, provinceName, cityName, areaName,
                    endRoadName, roadName));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getEndRoadName")
    @ResponseBody
    public JsonMsgDto getEndRoadName(Integer userId, Integer orgId, String startRoad, String provinceName, String cityName,
                                     String areaName, String roadName) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(highLeverLocationCountService.getEndRoadName(userId, orgId, startRoad, provinceName, cityName, areaName, roadName));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getHighLeverTypeCounts")
    @ResponseBody
    public JsonMsgDto getHighLeverTypeCounts(Integer userId, Integer orgId, String time, String province, String city, String area, String road) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(highLeverLocationCountService.getHighLeverTypeCounts(userId, orgId, time, province, city, area, road));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jsonMsgDto;
    }
}

